#include <algorithm>
#include <iostream>

using namespace std;

int encode_remainng_len(unsigned x, unsigned char encoded[]) {
    int i = 0;

    do {
        unsigned char digit = x % 128;
        x /= 128;

        if (x > 0) digit |= 0x80;

        encoded[i++] = digit;
    } while (x > 0);

    return i;
}

int decode_remainng_len(unsigned char encoded[], int max_size) {
    int           i          = 0;
    int           multiplier = 1;
    int           value      = 0;
    unsigned char digit;

    do {
        digit = encoded[i++];
        value += (digit & 127) * multiplier;
        multiplier *= 128;
        if (i > max_size) return -1;
    } while (digit & 128);

    return value;
}

int main() {
    int           x;
    unsigned char encoded[128];

    cin >> x;

    int n = encode_remainng_len(x, encoded);

    for (int i = 0; i < n; i++) {
        printf("%2X ", encoded[i]);
    }

    cout << endl;

    x = decode_remainng_len(encoded, n);

    cout << x << endl;

    return 0;
}
